import service from '@/utils/request'

export const templateGroupDetailApi = (id: Number) => {
	return service.get('/gen/template-group/' + id)
}

export const templateDetailApi = (id: Number) => {
	return service.get('/gen/template/' + id)
}

export const templateGroupSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.put('/gen/template-group/update', dataForm)
	} else {
		return service.post('/gen/template-group/add', dataForm)
	}
}

export const templateGroupListApi = () => {
	return service.get('/gen/template-group/list')
}

export const templateSubmitApi = (dataForm: any) => {
	if (dataForm.id) {
		return service.put('/gen/template/update', dataForm)
	} else {
		return service.post('/gen/template/add', dataForm)
	}
}

export const copyTemplateApi = (dataForm: any) => {
	return service.post('/gen/template-group/copy', dataForm)
}

export const exportTemplateGroupApi = (tableIdList: any) => {
	const listString = tableIdList.join(',')
	location.href =
		import.meta.env.VITE_API_URL + '/gen/template-group/export?idList=' + listString
}